﻿@model Web.Models.MovieHiresListViewModel

@{
    ViewBag.Title = "AllHires";
    Layout = "~/Views/Shared/WorkerLayout.cshtml";
}

<h2>Wszystkie wypożyczenia</h2>

 @using (Html.BeginForm())
            {
                <div class="form">
                    <div class="formtitle">Filtruj wyniki:</div>
                        <div class="input">
				            <div class="inputtext">Klient:</div>
				            <div class="inputcontent">
					            @Html.TextBoxFor(x => x.CustomerName)
				            </div>
			            </div>	
                        
                        <div class="input nobottomborder">
				            <div class="inputtext">Film</div>
				            <div class="inputcontent">
					            @Html.TextBoxFor(x => x.MovieTitle)
				            </div>
			            </div>
			            <div class="buttons">
				            <input class="orangebutton" type="submit" value="Szukaj" />
			            </div>
                </div>
            }

@if (Model != null && Model.Hires.Count<Hires>() > 0)
{
    <table class="list" style="width: 100%;">
        <thead>
            <tr>
                <td>Nazwa użytkownika</td>
                <td>Klient</td>
                <td>Film</td>
                <td>Nośnik</td>
                <td>Wypożyczony</td>
                <td>Do zwrotu</td>
                <td>Zakończone</td>
            </tr>
        </thead>
        @foreach (Hires hire in Model.Hires)
        {
                <tr>
                    <td>@hire.Users.UserDisplayName</td>
                    <td>@hire.Users.Customers.Persons.PersonFirstName @hire.Users.Customers.Persons.PersonLastName</td>
                    <td>@hire.Discs.Movies.MovieTitle</td>
                    <td>@hire.Discs.DiscTypes.DiscTypeName</td>
                    <td>@hire.HireSignupDate.ToString("dd.MM.yyyyy")</td>
                    <td>@hire.HirePlanningReturningDate.Value.ToString("dd.MM.yyyyy")</td>
                    <td>@string.Format("{0}",hire.HireIsDiscReturned?"Tak":"Nie")</td>
                 </tr>
        }
    </table>
    
    <div class="pagesNavigation">
        @Html.PageLinks(Model.PagingInfo, x => Url.Action("AllHires", new { page = x }))
    </div>
}
else
{
    <p>Aktualnie żaden użytkownik nie wypożycza nośników</p> 
}
